package cn.growthgate.fgo.service.impl;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import cn.growthgate.fgo.common.base.BaseServiceImpl;
import cn.growthgate.fgo.common.base.BaseVo;
import cn.growthgate.fgo.entity.ExceptionLog;
import cn.growthgate.fgo.entity.vo.ExceptionLogVo;
import cn.growthgate.fgo.mapper.ExceptionLogMapper;
import cn.growthgate.fgo.service.IExceptionLogService;

/**
 * <p>
 * 异常日志 服务实现类
 * </p>
 *
 * @author GrowthGate
 * @since 2019-05-10
 */
@Service
public class ExceptionLogServiceImpl extends BaseServiceImpl<ExceptionLogMapper, ExceptionLog> implements IExceptionLogService {

	@Override
	public BaseVo<ExceptionLog> transformVo(ExceptionLog exceptionLog) {
		ExceptionLogVo vo = new ExceptionLogVo();
		vo.setId(exceptionLog.getId());
		vo.setUser(baseMapper.getUser(exceptionLog));
		vo.setHost(exceptionLog.getHost());
		vo.setUri(exceptionLog.getUri());
		vo.setParams(JSON.parseObject(exceptionLog.getParams(), new TypeReference<Map<String, String[]>>(){}));
		vo.setName(exceptionLog.getName());
		vo.setStackTrace(exceptionLog.getStackTrace());
		vo.setAddTime(exceptionLog.getAddTime());
		return vo;
	}
	
}
